#include"process.h"
#include<stdio.h>
#include<unistd.h>


typedef void (*callback_t)(double total,double current);
double total = 1024.0;
double speed = 1.0;

//回调函数
void Download(callback_t cb)
{
	double current = 0;
	while(current <= total)
	{
		cb(total,current);
        //下载模块
		usleep(5000);
		current += speed;//充当下载数据
	}
	printf("\ndownload :%.2lfMB Done\n",current);
}

void Upload(callback_t cb)
{
	double current = 0;
	while(current <= total)
	{
		cb(total,current);
        //下载模块
		usleep(5000);
		current += speed;//充当下载数据
	}
	printf("\nupload :%.2lfMB Done\n",current);
}
int main()
{
	//myprocess_v1();//第一版进度条
	Download(FlushProcess);//现实版本
	Download(FlushProcess);
	Download(FlushProcess);
	Upload(FlushProcess);//fflushprocess函数解耦
	return 0;
}
